package com.example.sunflowers.data.repository

import com.example.sunflowers.data.db.GardenPlanting
import com.example.sunflowers.data.db.GardenPlantingDao
import javax.inject.Inject
import javax.inject.Singleton

/**
 *
 * @Author： LJH
 * @Time： 2024/1/26
 * @description：@Inject注解相当于创建对象的权力交给了hilt
 */
@Singleton
class GardenPlantingRepository @Inject constructor(
    private val gardenPlantingDao: GardenPlantingDao
) {

    suspend fun createGardenPlanting(plantId:String){
        val gardenPlanting = GardenPlanting(plantId)
        gardenPlantingDao.insertGardenPlanting(gardenPlanting)
    }

    suspend fun removeGardenPlanting(gardenPlanting: GardenPlanting){
        gardenPlantingDao.deleteGardenPlanting(gardenPlanting)
    }

    fun isPlanted(plantId: String) = gardenPlantingDao.isPlanted(plantId)

    fun getPlantedGardens() = gardenPlantingDao.getPlantedGardens()

}